package com.shuqing.dao;

import com.github.pagehelper.Page;
import com.shuqing.domain.Record;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
 * @program: ShuqingLibrary
 * @ClassName RecordMapper
 * @description:
 * @author: Ats
 * @create: 2025-04-07 16:10
 * @Version 1.0
 */
public interface RecordMapper {
  Integer addRecord(Record record);

  @Select({"<script>" +
          "select * from record " +
          "where 1=1 " +
          "<if test=\"bookname != null\"> AND  record_bookname  like CONCAT('%',#{bookname},'%')</if>" +
          "<if test=\"borrower != null\"> AND record_borrower like  CONCAT('%', #{borrower},'%') </if>" +
          "order by record_remandtime desc" +
          "</script>"
})
  @Results(id = "recordMap", value = {
          @Result(id = true, column = "record_id", property = "id"),
          @Result(column = "record_bookname", property = "bookname"),
          @Result(column = "record_bookisbn", property = "bookisbn"),
          @Result(column = "record_borrower", property = "borrower"),
          @Result(column = "record_borrowtime", property = "borrowTime"),
          @Result(column = "record_remandtime", property = "remandTime")

  })
  Page<Record> searchRecords(Record record);
}

